//
// Created by hugan on 2021/9/13.
//

#include <iostream>
#include "../dllJna/HttsJna.cpp"

using namespace std;

const wchar_t *text = L"hello2,今天的天气真好啊";

void printHr(const string &desc, HRESULT hr) {
    cout << desc << "=" << hr << endl;
}

void testSpeak() {
    setRate(5);
    printHr("setVolume", setVolume(100));

    speak(text);
}

void testStop() {
    setRate(2);
    speak(text);
    Sleep(1000);
    printHr("stop", stop());
}

void testPauseAndResume() {
    setRate(-2);
    speak(text);
    Sleep(1000);
    printHr("pause", pause());
    Sleep(2000);
    printHr("resume", resume());
}

void testMultiSpeak() {
    speak(text);
    Sleep(2000);
    speak(text);
}

void testChangeVoiceWhileSpeaking() {
    speak(text);
    Sleep(1000);
    setVoice(1);
    speak(text);
}

int main() {
    cout << "st" << endl;
//    SetConsoleOutputCP(65001);
    wprintf(L"%S\n", text);

    printHr("init", init(true));
    static int voiceInfoCount = 0;
//    func_enumVoiceCallback callback = [](VoiceInfo voiceInfo) -> void {
//        wprintf(L"voiceInfo.%d:%S\n", voiceInfoCount, voiceInfo.name);
//        voiceInfoCount++;
//    };
    func_enumVoiceCallback callback = [](wchar_t *name) -> void {
        wprintf(L"voiceInfo.%d:%S\n", voiceInfoCount, name);
        voiceInfoCount++;
    };
    printHr("enumVoice", enumVoice(callback));
    printHr("setVoice", setVoice(0));

    testSpeak();
//    testStop();
//    testPauseAndResume();
//    testMultiSpeak();
//    testChangeVoiceWhileSpeaking();

    cout << "sleep.st" << endl;
    Sleep(5000);
    doFree();
    cout << "ed" << endl;
    return 0;
}